package com.hopes.bizz.basic.park.enums;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.hopes.bizz.basic.common.constant.ParkDicConstant;
import com.hopes.bizz.basic.park.entity.BaseShiftQueueEntity;

import java.util.Date;

/**
 * @author: ljh
 * @create: 2024/1/24
 * 签到类型，上班，下班*
 */
public enum SignInType {
    ON_DUTY, OFF_DUTY;

    public String switchStatus(Date now, Date workStartDate, Date workEndDate) {
        switch (this) {
            case ON_DUTY:
                if (now.after(workStartDate)) {
                    return ParkDicConstant.sign_in_status_late;
                }
            case OFF_DUTY:
                if (now.before(workEndDate)) {
                    return ParkDicConstant.sign_in_status_early;
                }
            default:
                return ParkDicConstant.sign_in_status_normal;
        }
    }

    public SFunction<BaseShiftQueueEntity, ?> switchDate() {
        switch (this) {
            case ON_DUTY:
                return BaseShiftQueueEntity::getShiftSignDate;
            case OFF_DUTY:
                return BaseShiftQueueEntity::getShiftOffDutyDate;
            default:
                return null;
        }
    }
}
